<template>
  <div>
    <el-dialog
      title="工单配置"
      width="45%"
      :visible="dialogOpen"
      @close="handleClose"
    >

      <el-form>
        <el-form-item label="补货警戒线：">
          <el-input-number v-model="alertValue" controls-position="right" :min="0" :max="100" size="large" @change="handleChange" />
        </el-form-item>
      </el-form>

      <el-row slot="footer" type="flex" justify="center" align="middle" class="dialog-footer">
        <el-button type="warning" plain @click="handleClose">取消</el-button>
        <el-button v-loading="loading" type="primary" @click="submit">确认</el-button>
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
import { getAutoSupplyConfig, getSupplyAlertValue } from '@/api/task'
export default {
  props: {
    dialogOpen: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      num: 50,
      alertValue: 0,
      loading: false
    }
  },
  created() { this.getSupplyAlertValue() },
  methods: {
    handleClose() {
      this.$emit('update:dialogOpen', false)
    },
    handleChange(value) {
      // console.log(value)
    },

    async getSupplyAlertValue() {
      const { data } = await getSupplyAlertValue(50)
      // console.log(data)
      this.alertValue = data
    },
    async submit() {
      const { data } = await getAutoSupplyConfig(this.alertValue)
      console.log(data)
      this.handleClose()
    }
  }
}
</script>

<style lang="scss" scoped>
.el-form {
    padding: 0px 50px !important;
    width: 100%;
    .el-input-number {
     width: 396px !important;
    padding: 0 0 0 10px !important;
 ::v-deep.el-input-number__decrease {
    height: 20px !important;
    .el-icon-arrow-down {
        line-height: 20px;
    }
  }

  }
  ::v-deep label {
    font-weight: 400 !important;
  }

}
::v-deep .el-dialog__title {
    font-size: 16px !important;
    color: #333 !important;
    font-weight: 700;
}
.el-button--primary {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px!important;
    height: 36px;
    padding: 0;
    font-size: 14px;
    background: linear-gradient(135deg,#ff9743,#ff5e20)!important;
    border: none;
     margin-left: 50px !important;

  }
  .el-button--warning.is-plain {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px!important;
    height: 36px;
    padding: 0;
    background-color: #fbf4f0!important;
    border: none;
    color: #655b56!important;
      font-size: 14px;

  }

</style>
